import 'package:flame/game.dart';
import 'package:flutter/material.dart';

class MainCircle extends FlameGame{
  MainCircle({required this.position, this.radius = 20});
  
  final Vector2 position;
  final double radius;
  final Paint paint = Paint()..color = Colors.red;
  final Path path = Path();

  @override
  Future<void> onLoad() async{
    path.addOval(Rect.fromLTWH(position.x - radius, position.y - radius, radius * 2, radius * 2));
  }

  @override
  void render(Canvas canvas){
    canvas.drawCircle(position.toOffset(), radius, paint);
  }

  onPanUpdate(pos){
    position.setValues(pos.x, pos.y);
    _updatePath();
  }

  void _updatePath(){
    path.reset();
    path.addOval(Rect.fromLTWH(position.x - radius, position.y - radius, radius * 2, radius * 2));
  }
}